package FlappyBirds;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;

/**
 * 形象选择界面
 * 
 * @author bj
 *
 */
public class ImageSelection {
	int kind = 0;

	public static void main(String[] args) {
		new MenuJframe();
	}

	public ImageSelection() {

		JFrame frame = new JFrame("形象选择界面");

		frame.getContentPane().setLayout(null);
		frame.setBounds(100, 100, 700, 500);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.setLocationRelativeTo(null);

		/**
		 * 文字标签
		 */
		final JLabel sign = new JLabel("请选择一个你喜欢的形象：");
		sign.setBounds(40, 20, 300, 30);
		frame.getContentPane().add(sign);

		/**
		 * 小鸟形象的按钮
		 */
		final JButton bird = new JButton();
		bird.setIcon(new ImageIcon("D:\\Game\\FlappyBirdGame\\3.png"));
		bird.setBounds(100, 100, 100, 100);
		frame.getContentPane().add(bird);
		bird.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				int option1 = JOptionPane.showConfirmDialog(null, "确定以当前形象进入游戏？", "提示", JOptionPane.YES_NO_OPTION);
				if (option1 == JOptionPane.YES_OPTION) {
					frame.dispose();
					kind = 3;
					GameClient game = new GameClient(kind);
				}
			}
		});

		/**
		 * 蘑菇形象的按钮
		 */

		final JButton mushroom = new JButton();
		mushroom.setIcon(new ImageIcon("D:\\Game\\FlappyBirdGame\\4.png"));
		mushroom.setBounds(300, 100, 100, 100);
		frame.getContentPane().add(mushroom);
		mushroom.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				int option2 = JOptionPane.showConfirmDialog(null, "确定以当前形象进入游戏？", "提示", JOptionPane.YES_NO_OPTION);
				if (option2 == JOptionPane.YES_OPTION) {
					frame.dispose();
					kind = 4;
					GameClient game = new GameClient(kind);
				}
			}
		});

		/**
		 * 小马形象的按钮
		 */
		final JButton horse = new JButton();
		horse.setIcon(new ImageIcon("D:\\Game\\FlappyBirdGame\\5.png"));
		horse.setBounds(500, 100, 100, 100);
		frame.getContentPane().add(horse);
		horse.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				int option3 = JOptionPane.showConfirmDialog(null, "确定以当前形象进入游戏？", "提示", JOptionPane.YES_NO_OPTION);

				if (option3 == JOptionPane.YES_OPTION) {
					frame.dispose();
					kind = 5;
					GameClient game = new GameClient(kind);
				}
			}
		});
		/**
		 * 小马形象的按钮
		 */
		final JButton horse2 = new JButton();
		horse2.setIcon(new ImageIcon("D:\\Game\\FlappyBirdGame\\6.png"));
		horse2.setBounds(100, 300, 100, 100);
		frame.getContentPane().add(horse2);
		horse2.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				int option4 = JOptionPane.showConfirmDialog(null, "确定以当前形象进入游戏？", "提示", JOptionPane.YES_NO_OPTION);

				if (option4 == JOptionPane.YES_OPTION) {
					frame.dispose();
					kind = 6;
					GameClient game = new GameClient(kind);
				}
			}
		});

		/**
		 * 小鸟形象的按钮
		 */
		final JButton bird2 = new JButton();
		bird2.setIcon(new ImageIcon("D:\\Game\\FlappyBirdGame\\7.png"));
		bird2.setBounds(300, 300, 100, 100);
		frame.getContentPane().add(bird2);
		bird2.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				int option5 = JOptionPane.showConfirmDialog(null, "确定以当前形象进入游戏？", "提示", JOptionPane.YES_NO_OPTION);

				if (option5 == JOptionPane.YES_OPTION) {
					frame.dispose();
					kind = 7;
					GameClient game = new GameClient(kind);
				}
			}
		});

		/**
		 * 女巫形象的按钮
		 */
		final JButton witch = new JButton();
		witch.setIcon(new ImageIcon("D:\\Game\\FlappyBirdGame\\8.png"));
		witch.setBounds(500, 300, 100, 100);
		frame.getContentPane().add(witch);
		witch.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				int option6 = JOptionPane.showConfirmDialog(null, "确定以当前形象进入游戏？", "提示", JOptionPane.YES_NO_OPTION);

				if (option6 == JOptionPane.YES_OPTION) {
					frame.dispose();
					kind = 8;
					GameClient game = new GameClient(kind);
				}
			}
		});
		BackgroundPanel bgp = new BackgroundPanel(new ImageIcon("D:\\Game\\FlappyBirdGame\\9.png").getImage());
		bgp.setBounds(0, 0, 700, 500);
		frame.getContentPane().add(bgp);
		frame.setVisible(true);
	}
}
